import { All, Body, Controller, Query, Req } from '@nestjs/common';
import { GatewayService } from './gateway.service';

@Controller('api')
export class GatewayController {
  constructor(private readonly gatewayService: GatewayService) {}

  /**
   * // 捕获所有请求，包括动态路径
   * @param query 捕获 query 查询参数
   * @param body 捕获 body 请求体参数
   * @param request 捕获请求体信息(method请求方法 serviceName微服务名 path转发请求地址 params请求参数)
   * @returns
   */
  @All('*')
  async forwardRequest(
    @Query() query: any,
    @Body() body: any,
    @Req() request: any,
  ) {
    return this.gatewayService.TCPtranspond(query, body, request);
  }
}
